<template>
	<view class="myPrice" style="width: 80%; margin:0 auto;" >
		<view class="top">
			<view style="display: flex;align-items: center;justify-content: space-around;">
					<el-input v-model="queryParams.batchNum" placeholder="请输入订单号搜索" @blur="getList"></el-input>
					<el-radio-group 
						style="margin-left: 50rpx;display: flex;justify-content: space-around;width:300px" 
						v-model="queryParams.isBalance"
						@change="changeRadio"
					>
						<el-radio :label="0">全部</el-radio>
						<el-radio :label="1">未结算</el-radio>
						<el-radio :label="2">已结算</el-radio>
					</el-radio-group>
			</view>
			<view style="margin-left: 200rpx;font-size: 30rpx;">
				<text class="">今日生产: <text style="font-weight: bold;color: #e63f31;">{{countData.skirtSumToday || '--'}}</text> </text>
        <text class="" style="margin-left: 50rpx;">昨日生产: <text style="font-weight: bold;color: #e63f31;">{{countData.skirtSumYesterday || '--'}}</text></text>
        <text class="" style="margin-left: 50rpx;">本月生产: <text style="font-weight: bold;color: #e63f31;">{{countData.skirtSumCurrentMonth || '--'}}</text></text>
			</view>
		</view>
		<uni-table style="margin-top: 40rpx;" :stripe="false" border emptyText="暂无更多数据" >
			<!-- 表头行 -->
			<uni-tr>
				<uni-th width="50rpx" class="tab-header" align="center">序号</uni-th>
				<uni-th class="tab-header" align="center">客户订单号</uni-th>
				<uni-th class="tab-header" align="center">工序</uni-th>
				<uni-th class="tab-header" align="center">工价</uni-th>
				<uni-th class="tab-header" align="center">完成时间</uni-th>
				<uni-th class="tab-header" align="center">状态</uni-th>
			</uni-tr>
			<!-- 表格数据行 -->
			<uni-tr  v-for="(item, index) in tableData" :key="index">
				<uni-td class="tab-data" align="center">{{(page.page-1)*page.limit + index+1}}</uni-td>
				<uni-td class="tab-data" align="center">{{item.batchNum}}</uni-td>
				<uni-td class="tab-data" align="center">{{item.processName}}</uni-td>
				<uni-td class="tab-data" align="center">{{item.wages}}</uni-td>
				<uni-td class="tab-data" align="center">{{item.endTime}}</uni-td>
				<uni-td class="tab-data" align="center">{{item.status==1?'未结算':item.status==2?'已结算':''}}</uni-td>
			</uni-tr>
		</uni-table>
		<!-- 分页器 -->
		<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
			:current-page="page.page" :page-sizes="[10, 20, 30, 40]" :page-size="page.limit" :background="true"
			layout="total, sizes, pager, jumper" :total="total"
			style="font-size: 30rpx !important; text-align:right; margin: 10rpx 0;user-select: none !important;">
		</el-pagination>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				tableData:{},
        countData:{},
				queryParams:{
					isBalance:0,
					batchNum:''
				},
				page: {
					page: 1,
					limit: 10
				},
				total: 0,
			}
		},
		mounted(){
      this.getCount()
			this.getList()
		},
		methods:{
      // 获取统计
      getCount(){
        this.api.statisticsScanNum({}).then(res=>{
          console.log(res)
          this.countData = res.data.data
        })
      },
			// 切换页码
			handleCurrentChange(val) {
				this.page.page = val
				this.getList()
			},
			// 切换每页条数
			handleSizeChange(val) {
				this.page.limit = val
				this.page.page = 1 //切换之后要把当前页复位为 1
				this.getList()
			},
			getList(){
				this.api.myPrice({...this.queryParams, ...this.page}).then((res)=>{
					this.tableData = res.data.data.records
					this.total = res.data.data.total
				})
			},
			changeRadio(){
				this.getList()
			}
		}
	}
</script>

<style>
	.tab-header{
		background: #42B5FF;
		font-size: 27rpx;
		font-family: Microsoft YaHei;
		line-height: 26rpx;
		color: #FFFFFF;
		opacity: 1;
	}
	.tab-data{
		font-size: 24rpx;
	}
	.myPrice {
		width: 97%;
		margin: 0 auto;
	}
	
	.myPrice .top {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx;
		background-color: #fff;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
		overflow: scroll;
	
	}
	
	.myPrice .bottom {
		/* width: 100%; */
		background-color: #f5f5f5;
		overflow: auto;
		margin-top: 40rpx;
	}
</style>